import {createSlice, PayloadAction, Slice} from '@reduxjs/toolkit';

export type RuntimeInitialStateType = {
    nameSpaceId: string | null;
    nameSpaceName: string | null;
    nameSpaceLabel: string | null;
}

export const AppInitialState: RuntimeInitialStateType = {
    nameSpaceId: '',
    nameSpaceName: '',
    nameSpaceLabel: '',
}

const appSlice: Slice<RuntimeInitialStateType> = createSlice({
    name: 'app',
    initialState: AppInitialState,
    reducers: {
        updateNameSpace: (state, action: PayloadAction<RuntimeInitialStateType>) => {
            state.nameSpaceId = action.payload.nameSpaceId;
            state.nameSpaceName = action.payload.nameSpaceName;
            state.nameSpaceLabel = action.payload.nameSpaceLabel;
        },
    },
});

export const {updateNameSpace} = appSlice.actions;
export default appSlice.reducer;